<?  
	$title="Upload photo"; 
	$pageid="3";
	$accessid="a00";
	
	require("required/dbconnect.php");	
	require("required/function.php");
	require("required/header.php");
	
	
	$success=$_GET['success'];
	
	$id=$_GET['id'];
	
	
	
	//========================== upload affiliate member picture===================================
	if($success=="1")  
	{
		
		$pid=$_GET['pid'];
		$get_photo=mysql_query("select * from os_photogallery where id=$pid");
		
		$p=mysql_fetch_array($get_photo,MYSQL_ASSOC);
							
							
		$piclink=$p["name"];
		
		if($p["width"]>300 or $p["height"]>250)
		{
			if($p["width"]-$p["height"]>0)
			{
				$pfix="width=300";
				
			}
			else
			{
				$pfix="height=250";
				
			}						
		}
		else
		{
			$pfix="";
			
		}
		
		$caption=$p['caption'];
		
		
		$errormsg="Photo upload successfully!";
		$back="<img src='../photo_gallery/$piclink' $pfix border=0><br>$caption<br><br>
				(Please click <a href=# onClick=\"window.location.reload()\"><font color=\"#FF6600\">here</font></a> for the changes)<br><br>
				<input type=button value=\"Back\" onclick=\"window.open('photo_album_view.php?id=$id','_self')\" class=button>
				<input type=button value=\"Upload another one\" onclick=\"window.open('photo_upload.php?action=new&aid=$id','_self')\" class=button><br>";
	}
	elseif($success=="2")
	{
		$errormsg="Invalid file format, must in .jpg or .gif";
		$back="<input type=button value=\"Back\" onclick=\"window.open('photo_upload.php?action=new&id=$id','_self')\" class=button>";
	
	}
	elseif($success=="3")
	{
		$errormsg="Either the file is empty or the size is too large, please try again";
		$back="<input type=button value=\"Back\" onclick=\"window.open('photo_upload.php?action=new&id=$id','_self')\" class=button>";
	
	}
	elseif($success=="5")
	{
		$errormsg="Image resolution too large, max width is 2000px and max height is 1000px";
		$back="<input type=button value=\"Back\" onclick=\"history.go(-2)\" class=button>";
	
	}
	elseif($success=="6")
	{
		$errormsg="Image resolution too large, max width is 2000px and max height is 1000px";
		$back="<input type=button value=\"Back\" onclick=\"history.go(-2)\" class=button>";
	
	}
	elseif($success=="4")  
	{
		
		$photo_id=$_GET['pid'];
		$get_photo=mysql_query("select * from os_photogallery where id=$photo_id");
		
		$p=mysql_fetch_array($get_photo,MYSQL_ASSOC);
							
							
		$piclink=$p["name"];
		if($p["width"]>300 or $p["height"]>250)
		{
			if($p["width"]-$p["height"]>0)
			{
				$pfix="width=300";
				
			}
			else
			{
				$pfix="height=250";
				
			}						
		}
		else
		{
			$pfix="";
			
		}
		$caption=$p['caption'];
		
		
		$errormsg="Photo update successfully!";
		$back="<img src='../photo_gallery/$piclink' $pfix border=0><br>$caption<br><br>
				(Please click <a href=# onClick=\"window.location.reload()\"><font color=\"#FF6600\">here</font></a> for the changes)<br><br>
				<input type=button value=\"Back\" onclick=\"window.open('photo_album_view.php?id=$id','_self')\" class=button>";
	}
	else
	{
		$errormsg="Please select a photo to upload";
		$back="<input type=button value=\"Back\" onclick=\"window.open('photo_upload.php?action=new&id=$id','_self')\" class=button>";
	}
?>
<table width="100%"  cellpadding="0" cellspacing="5" height="300">

<td valign="top">
<table width="95%"  cellpadding="2" cellspacing="1">
	<td width="600" valign="top">
		<table width="100%" >
		<td align="center"><br><br>
		<font color=red><?= $errormsg ?></font><br><br>
		<?= $back ?><br><br>
		</td>
		</table><br>
	</td>
</table>
</td>
</table>

<? require("required/footer.php"); ?>